﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class playerFactory : MonoBehaviour
{
    // Start is called before the first frame update
    public GameObject PlayerPrefab;
    public GameObject BlackPoint;
    public List <GameObject> PlayerList;
    void Start()
    {
        //初始化生成一个角色
        PlayerList.Clear();
        AddPlayer();
    }

    public void AddPlayer() {    //添加一个角色
        PlayerList.Add((GameObject)Instantiate(PlayerPrefab, BlackPoint.transform.position, BlackPoint.transform.rotation));
    }
    public void DestroyPlayer(GameObject item){   //删除一个角色
        PlayerList.Remove(item);
    }

    public void SetBlackPoint(GameObject obj)  //设置回溯点
    {
        BlackPoint = obj;
    }
    public void ClearData() {
        foreach (var item in PlayerList)
        {
            item.GetComponent<TimeBack>().ClearData();//清空角色和残影的数据
        }
    }
    // Update is called once per frame
    void Update()
    {
        
    }
}
